package lingou.homework.postbar.service.tool;

import lingou.homework.postbar.domain.Post;
import lingou.homework.postbar.domain.User;
import lingou.homework.postbar.tool.StaticURL;

import java.sql.Timestamp;

public class Tools {
    public static Timestamp getNow(){
        return new Timestamp(System.currentTimeMillis());
    }
    public static String genAt(User user) {
        return "<a href= \"" + StaticURL.getUserHome(user.getUserId()) +"\">@" + user.getUserName() + "</a>";
    }
    public static String genPostLink(Post post){
        String postPreview = post.getPreview();
        if(postPreview.length() > 30) {
            postPreview = postPreview.substring(0, 30) + "...";
        }
        return "<a href= \"" + StaticURL.getPostLink(post.getPostId()) +"\">" + postPreview + "</a>";
    }
}
